import 'package:flutter/material.dart';

Widget ColumnStart({List<Widget> children}) {
  return Column(
      crossAxisAlignment: CrossAxisAlignment.start, children: children);
}

Widget RowBetween(
    {List<Widget> children, Key key, CrossAxisAlignment crossAxisAlignment}) {
  return Row(
      crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: children);
}

Widget MainTitle(String name) {
  return Text(name,
      style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500));
}

Widget TopRadiusbg(Color color) {
  return Container(
    height: 30.0,
    width: double.infinity,
    color: color,
  );
}

Widget Topradius({Color bgColor, Widget child, EdgeInsetsGeometry padding}) {
  return Stack(
    children: [
      TopRadiusbg(bgColor),
      Container(
        padding: padding,
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(10),
              topRight: Radius.circular(10),
            )),
        child: child,
      ),
    ],
  );
}

Widget TagContainer(String text, {double size,Color color,Widget icon}) {
  return Container(
    padding: EdgeInsets.symmetric(vertical: 3.0, horizontal: 5.0),
    decoration: BoxDecoration(
        color: (color??Colors.blueAccent).withOpacity(0.1),
        borderRadius: BorderRadius.only(topRight: Radius.circular(6))),
    child: Row(
      children: [
        Offstage(
            offstage: icon==null,
            child: Padding(
              padding: const EdgeInsets.only(right: 5),
              child: icon,
            ),
        ),
        Text(
          text,
          style: TextStyle(color: color ?? Colors.blueAccent, fontSize: size ?? 12.0),
        ),
      ],
    ),
  );
}

Widget ShadowContainer({Widget child}) {
  return Container(
    padding: EdgeInsets.fromLTRB(15.0, 15.0, 15.0, 5.0),
    decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(4.0),
        color: Colors.white,
        boxShadow: [
          BoxShadow(
              blurRadius: 2.0,
              spreadRadius: 1.0,
              color: Colors.black.withOpacity(0.09),
              offset: Offset(1.0, 1.0))
        ]),
    child: child,
  );
}

Widget HeadTitle(String text) {
  return Text(text, style: TextStyle(fontSize: 18));
}

Function GetBottomSheet(context,
    {List<Widget> children,
    String text,
    bool isScrollControlled,
    double height,
    EdgeInsetsGeometry padding}) {
  showModalBottomSheet(
      isScrollControlled: isScrollControlled ?? true,
      builder: (BuildContext context) {
        //构建弹框中的内容
        return Container(
          height: height ?? 420.0,
          child: Topradius(
              bgColor: Colors.black54,
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.only(left: 15.0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          text ?? "",
                          style: TextStyle(fontSize: 16),
                        ),
                        IconButton(
                            icon: Icon(Icons.close),
                            color: Colors.grey,
                            onPressed: () {
                              Navigator.pop(context);
                            })
                      ],
                    ),
                  ),
                  Expanded(
                    child: Container(
                      child: SingleChildScrollView(
                        child: Container(
                          padding:padding ?? EdgeInsets.only(left: 15.0),
                          child: Column(
                            children: children,
                          ),
                        ),
                      ),
                    ),
                  )
                ],
              )),
        );
      },
      context: context);
}

Widget VerticalDivideLine() {
  return SizedBox(
    width: 1,
    height: 20,
    child: DecoratedBox(
      decoration: BoxDecoration(color: Colors.grey.withOpacity(0.5)),
    ),
  );
}

Widget DarkHeadBar(String text,{List<Widget> actions}) {
  return AppBar(
    iconTheme: IconThemeData(
      color: Colors.black, //修改颜色
    ),
    backgroundColor: Colors.transparent,
    elevation: 0,
    title: Text(
      text,
      style: TextStyle(
          color: Colors.black87, fontSize: 16, fontWeight: FontWeight.w500),
    ),
    centerTitle: true,
    actions:actions
  );
}

Widget GreyContainer({Widget child, EdgeInsets margin, EdgeInsets padding}) {
  return Container(
      margin: margin,
      alignment: Alignment.center,
      padding:
          padding ?? EdgeInsets.symmetric(horizontal: 15.0, vertical: 15.0),
      decoration: BoxDecoration(
        color: Colors.grey.withOpacity(0.07),
        borderRadius: BorderRadius.circular(100),
      ),
      child: child);
}
